import request from '@/config/axios'

// 专业 VO
export interface MajorVO {
  id: number // 编号
  departId: number // 部门编号
  majorName: string // 专业名称
  description: string // 专业介绍
}
export interface DepartVo{
  id:number
  departName:string
}

export interface MajorForSelectVO {
  id: number // 编号
  majorName: string // 学校名称
}
export interface SchoolAndDepartTreeVo{
   id:number
   schoolName:string
   children:DepartVo[]
}

export interface MarjorAndDepartNameVo extends MajorVO{
  departName:string //部门名称
}


// 专业 API
export const MajorApi = {
  // 查询专业分页
  getMajorPage: async (params: any) => {
    return await request.get({ url: `/td/major/page`, params })
  },
  getMajorAndDepartNameRespVoPage:async (params: any)=>{
    return await request.get({ url: `/td/major/getMajorAndDepartNameRespVoPage`,params})
  },
  // 查询专业详情
  getMajor: async (id: number) => {
    return await request.get({ url: `/td/major/get?id=` + id })
  },
  // 新增专业
  createMajor: async (data: MajorVO) => {
    return await request.post({ url: `/td/major/create`, data })
  },

  // 修改专业
  updateMajor: async (data: MajorVO) => {
    return await request.put({ url: `/td/major/update`, data })
  },

  // 删除专业
  deleteMajor: async (id: number) => {
    return await request.delete({ url: `/td/major/delete?id=` + id })
  },

  // 导出专业 Excel
  exportMajor: async (params) => {
    return await request.download({ url: `/td/major/export-excel`, params })
  },

  getSchoolAndDepartmentTree: async ()=>{
    return await request.get({url:`/td/major/createSchoolAndDepartmentTree`})
  },

  getMajorsBySchoolId: async (schoolId) => {
    return await request.get({ url: `/td/major/getMajorsBySchoolId?schoolId=` + schoolId })
  },
  
}
